<?php
include'../King/hero.php';
if($islogin==1){}else exit("<script language='javascript'>window.location.href='login.php';</script>");
?>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <title><?php echo $conf['sitename']; ?>-网站配置</title>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <!--日期选择器css-->
    <link rel="stylesheet" type="text/css" href="js/bootstrap-datepicker/bootstrap-datepicker3.min.css">
    <!--时间日期选择器css-->
    <link rel="stylesheet" type="text/css" href="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css">
    <!--tags插件css-->
    <link rel="stylesheet" type="text/css" href="js/jquery-tagsinput/jquery.tagsinput.min.css">
    <!--对话框插件css-->
    <link rel="stylesheet" type="text/css" href="js/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.min.css">
    <style>
        button[type^="button"] {
            position: relative;
        }
        input[type^="file"] {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            -webkit-opacity: 0;
            opacity: 0;
        }
    </style>
</head>

<body>
    <div class="container-fluid">

        <div class="row">

            <div class="col-lg-12">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">网站配置</div>
                    </header>
                    <div class="card-body">
                        <div class="edit-form">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="config" aria-labelledby="basic-config">
                                    <div class="mb-3">
                                        <label for="web_site_main_title" class="form-label">网站主标题</label>
                                        <input class="form-control" type="text" id="sitename" name="web_site_main_title" value="<?php echo $conf['sitename']; ?>" placeholder="请输入站点主标题">
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_secondary_title" class="form-label">网站副标题</label>
                                        <input class="form-control" type="text" id="title" name="web_site_secondary_title"
                                            value="<?php echo $conf['title']; ?>" placeholder="请输入站点副标题">
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_logo" class="form-label">站点ico图片</label>
                                        <div class="input-group">
                                            <input type="file" id="file" onchange="fileUpload()" style="display:none;"/>
                                            <input type="text" class="form-control" id="ico"name="web_site_logo" value="<?php echo $conf['ico']; ?>">
                                            <button class="btn btn-default" type="file"onclick="fileSelect()">上传ico</button>
                                        </div>
                                    </div>
                                   
                                    <div class="mb-3">
                                        <label for="web_site_keywords" class="form-label">站点关键词</label>
                                        <input class="form-control" type="text" id="keywords" name="web_site_keywords" value="<?php echo $conf['keywords']; ?>" placeholder="请输入站点关键词">
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_description" class="form-label">站点描述</label>
                                        <textarea class="form-control" id="description" rows="3" name="web_site_description" placeholder="请输入站点描述"><?php echo $conf['description']; ?></textarea>
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_pic" class="form-label">首页头像</label>
                                        <div class="input-group">
                                            <input type="file" id="fileb" onchange="fileUploadb()" style="display:none;"/>
                                            <input type="text" class="form-control" id="logo"value="<?php echo $conf['logo']; ?>">
                                            <button class="btn btn-default" type="file" onclick="fileSelectb()">上传首页头像</button>
                                        </div>
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_weixin" class="form-label">微信二维码</label>
                                        <div class="input-group">
                                            <input type="file" id="filea" onchange="fileUploada()" style="display:none;"/>
                                            <input type="text" class="form-control" id="ewm"value="<?php echo $conf['ewm']; ?>">
                                            <button class="btn btn-default" type="file"onclick="fileSelecta()">上传微信二维码</button>
                                        </div>
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_weixin" class="form-label">QQ二维码</label>
                                        <div class="input-group">
                                            <input type="file" id="filec" onchange="fileUploadc()" style="display:none;"/>
                                            <input type="text" class="form-control" id="qqewm"value="<?php echo $conf['qqewm']; ?>">
                                            <button class="btn btn-default" type="file"onclick="fileSelectc()">上传QQ二维码</button>
                                        </div>
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_qq" class="form-label">QQ号</label>
                                        <input class="form-control" type="text" id="kfqq" name="web_site_qq" value="<?php echo $conf['kfqq']; ?>"
                                            placeholder="请输入你的QQ号">
                                        <small class="form-text">跳转你QQ的链接</small>
                                    </div>
                                      <div class="mb-3">
                                        <label for="web_site_qq" class="form-label">小枫音乐播放器key【不填则不展示】</label>
                                        <input class="form-control" type="text" id="akey" name="web_site_qq" value="<?php echo $conf['akey']; ?>"
                                            placeholder="请输入你的key">
                                        <small class="form-text">申请网站：<a href="https://music.xfyun.club/" target="_blank" rel="noopener noreferrer">https://music.xfyun.club</a><span style="color: red;"> (免费)</span></small>
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_runTime" class="form-label">本站运行时间</label>
                                        <input type="text" class="form-control" data-provide="datepicker" data-autoclose="true" name="web_site_runTime" id="time"value="<?php echo $conf['time']; ?>" placeholder="请输入网站运行时间">
                                    </div>
                                    <div class="mb-3">
                                        <label for="web_site_icp" class="form-label">备案信息</label>
                                        <input class="form-control" type="text" id="copyright" name="web_site_icp"
                                            value="<?php echo $conf['copyright']; ?>" placeholder="请输入备案信息">
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">站点开关</label>
                                        <div class="form-check form-switch">
                                            <input type="checkbox" class="form-check-input" id="wzkg"
                                        <?php if($conf['wzkg']==1){ ?>
                                            checked="true"value="2" <?php }else{ ?> value="1"checked="false" <?php } ?> >
                                            <label class="form-check-label" for="web_site_switch"></label>
                                        </div>
                                        <small class="form-text">站点关闭后将不能访问，后台可正常登录</small>
                                    </div>
                                    <div>
                                        <button class="btn btn-primary me-1"onclick="set()">确 定</button>
                                    </div>

                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

        </div>

    </div>

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/popper.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/fireworks.js"></script>
    <!--日期选择器js-->
    <script type="text/javascript" src="js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
    <!--时间日期选择器js-->
    <script type="text/javascript" src="js/momentjs/moment.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="js/momentjs/locale/zh-cn.min.js"></script>
    <!--tags插件-->
    <script type="text/javascript" src="js/jquery-tagsinput/jquery.tagsinput.min.js"></script>
    <!--对话框插件js-->
    <script type="text/javascript" src="js/jquery-confirm/jquery-confirm.min.js"></script>
    <script type="text/javascript" src="js/main.min.js"></script>
    <script>
    function fileSelect(){
	$("#file").trigger("click");
}
       function fileUpload(){
	var fileObj = $("#file")[0].files[0];
	if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
		return;
	}
	var formData = new FormData();
	formData.append("do","upload");
	formData.append("type","ico");
	formData.append("file",fileObj);
	
	$.ajax({
		url: "./ajax.php?act=uploadimg",
		data: formData,
		type: "POST",
		dataType: "json",
		cache: false,
		processData: false,
		contentType: false,
		success: function (data) {
			
			if(data.code == 0){
				 $.alert({
                                title: '提示',
                                content: '上传图片成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
				$("#ico").val(data.url);
			}else{
					$.alert({
                                title: '提示',
                                content: data.msg,
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			}
		},
		error:function(data){
				$.alert({
                                title: '提示',
                                content: '服务器错误！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			return false;
		}
	})
}
function fileSelecta(){
	$("#filea").trigger("click");
}
       function fileUploada(){
	var fileObj = $("#filea")[0].files[0];
	if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
		return;
	}
	var formData = new FormData();
	formData.append("do","upload");
	formData.append("type","ewm");
	formData.append("file",fileObj);
	
	$.ajax({
		url: "./ajax.php?act=uploadimga",
		data: formData,
		type: "POST",
		dataType: "json",
		cache: false,
		processData: false,
		contentType: false,
		success: function (data) {
			
			if(data.code == 0){
				 $.alert({
                                title: '提示',
                                content: '上传图片成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
				$("#ewm").val(data.url);
			}else{
					$.alert({
                                title: '提示',
                                content: data.msg,
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			}
		},
		error:function(data){
				$.alert({
                                title: '提示',
                                content: '服务器错误！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			return false;
		}
	})
}
function fileSelectb(){
	$("#fileb").trigger("click");
}
       function fileUploadb(){
	var fileObj = $("#fileb")[0].files[0];
	if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
		return;
	}
	var formData = new FormData();
	formData.append("do","upload");
	formData.append("type","logo");
	formData.append("file",fileObj);
	
	$.ajax({
		url: "./ajax.php?act=uploadimgb",
		data: formData,
		type: "POST",
		dataType: "json",
		cache: false,
		processData: false,
		contentType: false,
		success: function (data) {
			
			if(data.code == 0){
				 $.alert({
                                title: '提示',
                                content: '上传图片成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
				$("#logo").val(data.url);
			}else{
					$.alert({
                                title: '提示',
                                content: data.msg,
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			}
		},
		error:function(data){
				$.alert({
                                title: '提示',
                                content: '服务器错误！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			return false;
		}
	})
}
function fileSelectc(){
	$("#filec").trigger("click");
}
       function fileUploadc(){
	var fileObj = $("#filec")[0].files[0];
	if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
		return;
	}
	var formData = new FormData();
	formData.append("do","upload");
	formData.append("type","qqewm");
	formData.append("file",fileObj);
	
	$.ajax({
		url: "./ajax.php?act=uploadimgc",
		data: formData,
		type: "POST",
		dataType: "json",
		cache: false,
		processData: false,
		contentType: false,
		success: function (data) {
			
			if(data.code == 0){
				 $.alert({
                                title: '提示',
                                content: '上传图片成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
				$("#qqewm").val(data.url);
			}else{
					$.alert({
                                title: '提示',
                                content: data.msg,
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			}
		},
		error:function(data){
				$.alert({
                                title: '提示',
                                content: '服务器错误！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
			return false;
		}
	})
}
      function set(){//系统配置
        var sitename= $("#sitename").val(); 
        var title= $("#title").val(); 
        var keywords= $("#keywords").val(); 
        var description= $("#description").val(); 
        var ico= $("#ico").val(); 
        var time= $("#time").val(); 
        var ewm= $("#ewm").val();
        var qqewm= $("#qqewm").val(); 
	
	
        var kfqq= $("#kfqq").val(); 
        var logo= $("#logo").val();
        var wzkg= $("#wzkg").val(); 
        var akey= $("#akey").val(); 
        var copyright= $("#copyright").val();        
	
		

		  	$.ajax({
				type : "POST",
				url : "./ajax.php?act=czset",
				data : {sitename,title,keywords,description,time,ewm,wzkg,ico,kfqq,copyright,logo,akey,qqewm},
				dataType : 'json',
		
				success : function(data) {					  
					if(data.code==1){
					  $.alert({
                                title: '提示',
                                content: '提交成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
					  
						setTimeout(function () {
							location.href="./config.php";
						}, 1000); //延时1秒跳转
					  }
				},
				error:function(data){
					$.alert({
                                title: '提示',
                                content: '提交失败！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
					}
			});
		  	
}
    </script>
</body>

</html>